Octree Generation

require.mx('mxjs/mesh/octree.js');

This is the octree generation library.

StatusName
Constant Number BF_INTERSECTED

box flag indicating that a box intersected the mesh

Constant Number BF_NONE

empty box flags

Constant Number BF_SUBDIVIDED

box flag indicating that a box was subdivided

copyBoxCentre ( vec3 ↑outLocation, Object ↓boxes, Number ↓idx )

generateSteppedOctree ( Object settings )

wasBoxIntersected ( Object ↓boxes, Number ↓idx )

wasBoxSubdivided ( Object ↓boxes, Number ↓idx )


Library Functions

Lib.copyBoxCentre ( ↑outLocation, ↓boxes, ↓idx )

Parameters:
  • vec3 ↑outLocation - vector or array to copy the location into
  • Object ↓boxes - an object from the boxesByLevel array returned by generateSteppedOctree
  • Number ↓idx - index of the box to check
Lib.generateSteppedOctree ( settings )

Parameters:
  • Object settings - settings for the octree generation. resolution a number specifying the size of the minimum cubes to generate. mesh a LibMeshTA mesh object containing the mesh to divide space around. boundingMin and boundingMax, vectors specifying the minimum point and maximum point of the volume to divide (an axis aligned cuboid). generateNearbySteps determines whether blocks are subdivided near (but not intersecting) the mesh, used to generate staggered cube size increases around the mesh (e.g. for generate numerical modelling analysis points), defaults to false. calculateIntersections determines whether the intersect flag should be calculated for the final level of cubes, defaults to true. levelSteps an optional array specifying hopeful numbers of the levels of cubes for each size level, as moving away from the mesh, e.g. [4, 2, 2] would aim to create four layers of minimum size cubes, two layers of the next size cube, and two layers of the third size - unspecified levels are assumed to be 1. Note that the real number of layers generated is highly dependent on the position within the volume due to how the octree is divided.
Lib.wasBoxIntersected ( ↓boxes, ↓idx )

Parameters:
  • Object ↓boxes - an object from the boxesByLevel array returned by generateSteppedOctree
  • Number ↓idx - index of the box to check
Lib.wasBoxSubdivided ( ↓boxes, ↓idx )

Parameters:
  • Object ↓boxes - an object from the boxesByLevel array returned by generateSteppedOctree
  • Number ↓idx - index of the box to check